package com.vipheyue.huaxue.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.vipheyue.huaxue.R;
import com.vipheyue.huaxue.activity.SearchActivity;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * A simple {@link Fragment} subclass.
 */
public class DrawerFragment extends Fragment {


    @Bind(R.id.tv_search)
    TextView tv_search;
    @Bind(R.id.tv_order)
    TextView tv_order;
    @Bind(R.id.list_container)
    LinearLayout list_container;
    @Bind(R.id.detail_container)
    LinearLayout detail_container;

    public DrawerFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment

        Fragment listFragment = new BrowseMenuLeftFragment();
        Fragment detailFragment = new BrowseMenuRightFragment();
        FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.add(R.id.list_container, listFragment);
        fragmentTransaction.add(R.id.detail_container, detailFragment);
        fragmentTransaction.commit();
        View view = inflater.inflate(R.layout.activity_browse_menu, container, false);
        ButterKnife.bind(this, view);
        return view;
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @OnClick({R.id.tv_search, R.id.tv_order})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_search:
//                Toast.makeText(getActivity(), "search", Toast.LENGTH_SHORT).show();
                startActivity(new Intent(getActivity(), SearchActivity.class));
                break;
            case R.id.tv_order:
//                Toast.makeText(getActivity(), "order®", Toast.LENGTH_SHORT).show();
                break;
        }
    }
}
